package com.hzlj.position.config.converter;

import com.hzlj.position.config.common.dto.jzJbxxDeviceBind.JzJbxxDeviceBindAddDTO;
import com.hzlj.position.config.common.dto.jzJbxxDeviceBind.JzJbxxDeviceBindQueryResultDTO;
import com.hzlj.position.config.common.dto.jzJbxxDeviceBind.JzJbxxDeviceBindUpdateDTO;
import com.hzlj.position.config.common.model.JzJbxxDeviceBind;
import com.fz.common.base.converter.ModelDTOConverter;
import com.fz.common.base.core.date.DateUtils;

/**
 * 设备绑定表(JzJbxxDeviceBind)DTO转换类
 *
 * @author lifh
 * @date 2023-03-13 16:57:41
 */
public class JzJbxxDeviceBindConverter {
    /**
     * model实例转换为查询结果DTO
     *
     * @param model model实例
     * @return DTO
     */
    public static JzJbxxDeviceBindQueryResultDTO from(JzJbxxDeviceBind model) {
        return ModelDTOConverter.from(model, JzJbxxDeviceBindQueryResultDTO.class);
    }

    /**
     * 新增DTO转换为model实例
     *
     * @param dto 新增DTO
     * @return model实例
     */
    public static JzJbxxDeviceBind from(JzJbxxDeviceBindAddDTO dto) {
        return ModelDTOConverter.from(dto, JzJbxxDeviceBind.class, (JzJbxxDeviceBind l) -> {
            l.setValid(true);
            l.setUpdateTime(DateUtils.now());
            l.setCreateTime(DateUtils.now());
        });

    }

    /**
     * 修改DTO转换为model实例
     *
     * @param dto 修改DTO
     * @return model实例
     */
    public static JzJbxxDeviceBind from(JzJbxxDeviceBindUpdateDTO dto) {
        return ModelDTOConverter.from(dto, JzJbxxDeviceBind.class, (JzJbxxDeviceBind l) -> {
            l.setUpdateTime(DateUtils.now());
        });
    }
}
